package com.ruoyi.web.controller.broadcast;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.broadcast.domain.Gbss;
import com.ruoyi.broadcast.service.IGbssService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 广播实时Controller
 * 
 * @author hcc
 * @date 2024-12-01
 */
@RestController
@RequestMapping("/control/gbss")
public class GbssController extends BaseController
{
    @Autowired
    private IGbssService gbssService;

    /**
     * 查询广播实时列表
     */
    @PreAuthorize("@ss.hasPermi('control:gbss:list')")
    @GetMapping("/list")
    public TableDataInfo list(Gbss gbss)
    {
        startPage();
        List<Gbss> list = gbssService.selectGbssList(gbss);
        return getDataTable(list);
    }

    /**
     * 导出广播实时列表
     */
    @PreAuthorize("@ss.hasPermi('control:gbss:export')")
    @Log(title = "广播实时", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Gbss gbss)
    {
        List<Gbss> list = gbssService.selectGbssList(gbss);
        ExcelUtil<Gbss> util = new ExcelUtil<Gbss>(Gbss.class);
        util.exportExcel(response, list, "广播实时数据");
    }

    /**
     * 获取广播实时详细信息
     */
    @PreAuthorize("@ss.hasPermi('control:gbss:query')")
    @GetMapping(value = "/{broadcastRealId}")
    public AjaxResult getInfo(@PathVariable("broadcastRealId") String broadcastRealId)
    {
        return success(gbssService.selectGbssByBroadcastRealId(broadcastRealId));
    }

    /**
     * 新增广播实时
     */
    @PreAuthorize("@ss.hasPermi('control:gbss:add')")
    @Log(title = "广播实时", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Gbss gbss)
    {
        return toAjax(gbssService.insertGbss(gbss));
    }

    /**
     * 修改广播实时
     */
    @PreAuthorize("@ss.hasPermi('control:gbss:edit')")
    @Log(title = "广播实时", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Gbss gbss)
    {
        return toAjax(gbssService.updateGbss(gbss));
    }

    /**
     * 删除广播实时
     */
    @PreAuthorize("@ss.hasPermi('control:gbss:remove')")
    @Log(title = "广播实时", businessType = BusinessType.DELETE)
	@DeleteMapping("/{broadcastRealIds}")
    public AjaxResult remove(@PathVariable String[] broadcastRealIds)
    {
        return toAjax(gbssService.deleteGbssByBroadcastRealIds(broadcastRealIds));
    }
}
